package com.aboo.service.impl;

import java.util.Iterator;
import java.util.List;

import com.aboo.dao.FrameResultDao;
import com.aboo.po.FrameResultPO;
import com.aboo.po.Page;
import com.aboo.pub.exception.BasicException;
import com.aboo.pub.result.ResultConstant;
import com.aboo.pub.result.ResultInfo;
import com.aboo.service.FrameResultService;

public class FrameResultServiceImpl implements FrameResultService {
	
	private FrameResultDao frameResultDao;

	public void saveFrameResult(ResultInfo ri, FrameResultPO param)
			throws BasicException {
		try {
			frameResultDao.save(param);
			ri.setResultCode(ResultConstant.STATUS_OK);
		} catch (Exception ex) {
			throw new BasicException("保存结果信息时出错", ex);
		}
	}

	public void deleteFrameResult(ResultInfo ri, List<Integer> resultIds)
			throws BasicException {
		try {
			if (resultIds != null) {
				Integer resultId = null;
				for (Iterator<Integer> iter = resultIds.iterator(); iter.hasNext();) {
					resultId = iter.next();
					frameResultDao.delete(resultId);
				}
			}
			ri.setResultCode(ResultConstant.STATUS_OK);
		} catch (Exception ex) {
			throw new BasicException("删除结果信息时出错", ex);
		}
	}

	public void updateFrameResult(ResultInfo ri, FrameResultPO param)
			throws BasicException {
		try {
			frameResultDao.update(param);
			ri.setResultCode(ResultConstant.STATUS_OK);
		} catch (Exception ex) {
			throw new BasicException("保存结果信息时出错", ex);
		}
	}

	public void findFrameResultList(ResultInfo ri, FrameResultPO param,
			Page page) throws BasicException {
		try {
			List<FrameResultPO> result = frameResultDao.findList(param, page);
			ri.setResultCode(ResultConstant.STATUS_OK);
			ri.setObj(result);
		} catch (Exception ex) {
			throw new BasicException("查询结果信息时出错", ex);
		}
	}

	public FrameResultDao getFrameResultDao() {
		return frameResultDao;
	}
	public void setFrameResultDao(FrameResultDao frameResultDao) {
		this.frameResultDao = frameResultDao;
	}

}
